﻿<DemoContainer>
    <ApexChart TItem="Order" Title="Orders Value"
               XAxisType="XAxisType.Datetime"
               Options="options">

        <ApexPointSeries TItem="Order"
                         Items="SampleData.GetOrders()"
                         Name="Net Value"
                         SeriesType="SeriesType.Line"
                         XValue="@(e => e.OrderDate.FirstDayOfMonth())"
                         YAggregate="@(e => e.Sum(e => e.NetValue))"
                         OrderBy="e=>e.X" />

        <ApexPointSeries TItem="Order"
                         Items="SampleData.GetOrders()"
                         Name="Gross Value"
                         SeriesType="SeriesType.Line"
                         XValue="@(e => e.OrderDate.FirstDayOfMonth())"
                         YAggregate="@(e => e.Sum(e => e.GrossValue))"
                         OrderBy="e=>e.X" />
    </ApexChart>
</DemoContainer>

@code {
    private ApexChartOptions<Order> options = new ApexCharts.ApexChartOptions<Order>();
    protected override void OnInitialized()
    {
        options.Chart = new Chart
            {
                Toolbar = new Toolbar
                {
                    Export = new ExportOptions
                    {
                        Csv = new ExportCSV
                        {
                            Filename = "Test Date formatter",
                            HeaderCategory = "sep=|" + Environment.NewLine + "Date",
                            ColumnDelimiter = "|",
                            DateFormatter = "function (value) {  return new Date(value).toLocaleString(); }"
                            
                        }
                    }
                }
            };
    }
}
